/*
 * @Script: t5.c
 * @Author: ystlong
 * @Email: ystlong@163.com
 * @Create At: yyyy-03-dd 21:00:47
 * @Last Modified By: ystlong
 * @Last Modified At: yyyy-03-dd 21:00:47
 * @Description: This is description.
 */

#include <stdio.h>
#include <string.h>

typedef struct cinfo{
    char c;
    short n;
}cinfo_t;

int update_c_info(cinfo_t *cinfos, char c, int len)
{
    int i;
    for(i=0; i<len; i++){
        if(cinfos[i].c == c){
            break;
        }else if (cinfos[i].c == 0){
            cinfos[i].c = c;
            break;
        }
    }
    ++cinfos[i].n;
    return i;
}

void show_mm_str(const char *str, int len)
{
    cinfo_t *cinfos = malloc(len*sizeof(cinfo_t));
    int max_i =0, min_i =0;
    memset(cinfos, 0, sizeof(cinfo_t)*len);
    char c;
    while(c=*str++){
        int c_i = update_c_info(cinfos, c, len);
        if (cinfos[c_i].n > cinfos[max_i].n || (cinfos[c_i].n == cinfos[max_i].n && c_i < max_i)) max_i = c_i;
        if (cinfos[c_i].n < cinfos[min_i].n) min_i = c_i;
    }
    for(int i=0; i<min_i; i++){
        if(cinfos[i].n <= cinfos[min_i].n){
            min_i = i;
            break;
        } 
    }
    printf("min n c: %c (%d), max n c: %c (%d)\n", 
    cinfos[min_i].c, cinfos[min_i].n, cinfos[max_i].c, cinfos[max_i].n);
}

int main()
{
    char buf[101];
    scanf("%s", buf);
    show_mm_str(buf, strlen(buf));
    return 0;
}